package com.summer.bilibiliLeetcode._01;

public class _01 {
    public static void main(String[] args) {
        char[] str1= new char[]{'a','b','c','d','e','f'};
        char[] str2= new char[]{'b','z','d'};
//        int a = (int)str1[0];
//        System.out.println(a);
        String s2 = String.valueOf(str2);
        int hashStr2 = str2[0]+str2[1]+str2[2];
        for (int i = 0;i<=str1.length-3;i++){
            int hashStr1 =str1[i]+str1[i+1]+str1[i+2];
           boolean isTure = isHash(hashStr1, hashStr2);
           if (isTure){
               char[] str = new char[3];
               int k = i;
               for (int j =0;j<3;j++){
                   str[j]=str1[k++];
               }
               String s1 = String.valueOf(str);
               boolean contain = isContain(s1, s2);
               if (contain)
                   System.out.printf("存在子串，下标为%d",i);
               break;
               }

           }
        System.out.println("不存在子串");
        }
    static boolean isHash(int hash1,int hash2){
        if (hash1==hash2)return true;
        return false;
    }
    static boolean isContain(String str1 ,String str2){
       if (str1.equals(str2)) return true;
        else return false;
    }

    }



